﻿using System;

namespace Framework.Validation.Implementation
{
    /// <summary>
    /// Represents the result of a validation.
    /// </summary>
    public class ValidationResult : IValidationResult
    {
        private readonly string message;
        private readonly object target;
        private readonly IValidator validator;

        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationResult"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="target">The target.</param>
        /// <param name="validator">The validator.</param>
        public ValidationResult(string message, object target, IValidator validator)
        {
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentException("Please, specify the message.", "message");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (validator == null)
            {
                throw new ArgumentNullException("validator");
            }

            this.message = message;
            this.target = target;
            this.validator = validator;
        }

        /// <inheritdoc />
        public string Message
        {
            get
            {
                return message;
            }
        }

        /// <inheritdoc />
        public object Target
        {
            get
            {
                return target;
            }
        }

        /// <inheritdoc />
        public IValidator Validator
        {
            get
            {
                return validator;
            }
        }
    }
}
